//SingletonTest1.java
package com.ylaihui.oop10;

class Order {
	// 1. 私有化构造器
	private Order(){}
	
	// 2. 定义一个私有的属性
	private static Order instance = null;
	
	// 3. 提供一个static方法
	public static Order getInstance() {
		if(instance == null)
			instance = new Order();
		return instance;
	}
}
public class SingletonTest1 {
	public static void main(String[] args) {
		Order inst1 = Order.getInstance();
		Order inst2 = Order.getInstance();
		
		System.out.println(inst1 == inst2);  // true
	}
}
